#define fexit(s) { fprintf( stderr, "%s\n", s ); exit(1); }
#include <stdio.h>
#include <stdlib.h>
#include "../../jerasure-2.h"

int main( int argc, char** argv )
{
	JER_Matrix *matrix;
	int r = atoi( argv[1] );
	int c = atoi( argv[2] );
	int w = atoi( argv[3] );
	int i, fsize;

	matrix = new JER_Matrix( r, c, w );
	if( matrix == NULL )
		fexit( "Matrix could not be allocated." );
	srand48(c);
	fsize = 1 << w;
	for( i = 0; i < r * c; i++ )
		matrix->Elts[i/c][i%c] = lrand48() % fsize;
	for( i = 0; i < (r/2) * (c/2); i++ )
		matrix->Elts[r/2+(i/(c/2))][c/2+(i%(c/2))] ^= lrand48() % fsize;
	matrix->Print();

	return 0;
}
